--This Test Should have 2 children for both pass and fail task
DECLARE

	v_SweepProp_Seq1 INTEGER;
	v_SweepProp_Seq2 INTEGER;
	v_SweepProp_Seq3 INTEGER;
	v_SweepProp_Seq4 INTEGER;
	v_RequestDefnId  INTEGER;
	v_SweepFI_Seq1 INTEGER;
	v_SweepFI_Seq2 INTEGER;
	v_SweepFI_Seq3 INTEGER;
BEGIN
	INSERT INTO AUTOSC.CFG_REQUEST_TYPE (REQUEST_TYPE_ID, REQUEST_TYPE_NAME, IS_REQUESTABLE) VALUES(CFG_REQUEST_TYPE_SEQ.nextVal, 'JUNIT_TEST_REQUEST_TYPE_07', 'Y');
	
	INSERT INTO AUTOSC.CFG_TASK_TYPE ( TASK_TYPE_ID, TASK_TYPE_NAME, TASK_CATEGORY_ID, MAX_RETRY_COUNT, CODE_GROUP, EXT_AUTOSC, PRIORITY, RUNTIME_LENGTH) VALUES ( CFG_TASK_TYPE_SEQ.nextVal, 'JUNIT_TEST_TASK_TYPE_07_A', (SELECT TASK_CATEGORY_ID FROM AUTOSC.CFG_TASK_CATEGORY_INFO WHERE TASK_CATEGORY='SWEEP'), 2, 'D', 'T', 5, 1440 );
	INSERT INTO AUTOSC.CFG_TASK_TYPE ( TASK_TYPE_ID, TASK_TYPE_NAME, TASK_CATEGORY_ID, MAX_RETRY_COUNT, CODE_GROUP, EXT_AUTOSC, PRIORITY, RUNTIME_LENGTH) VALUES ( CFG_TASK_TYPE_SEQ.nextVal, 'JUNIT_TEST_TASK_TYPE_07_B', (SELECT TASK_CATEGORY_ID FROM AUTOSC.CFG_TASK_CATEGORY_INFO WHERE TASK_CATEGORY='GATHER'), 2, 'D', 'T', 5, 1440 );
	INSERT INTO AUTOSC.CFG_TASK_TYPE ( TASK_TYPE_ID, TASK_TYPE_NAME, TASK_CATEGORY_ID, MAX_RETRY_COUNT, CODE_GROUP, EXT_AUTOSC, PRIORITY, RUNTIME_LENGTH) VALUES ( CFG_TASK_TYPE_SEQ.nextVal, 'JUNIT_TEST_TASK_TYPE_07_C', (SELECT TASK_CATEGORY_ID FROM AUTOSC.CFG_TASK_CATEGORY_INFO WHERE TASK_CATEGORY='GATHER'), 2, 'D', 'T', 5, 1440 );
	INSERT INTO AUTOSC.CFG_TASK_TYPE ( TASK_TYPE_ID, TASK_TYPE_NAME, TASK_CATEGORY_ID, MAX_RETRY_COUNT, CODE_GROUP, EXT_AUTOSC, PRIORITY, RUNTIME_LENGTH) VALUES ( CFG_TASK_TYPE_SEQ.nextVal, 'JUNIT_TEST_TASK_TYPE_07_D', (SELECT TASK_CATEGORY_ID FROM AUTOSC.CFG_TASK_CATEGORY_INFO WHERE TASK_CATEGORY='GATHER'), 2, 'D', 'T', 5, 1440 );
	
	SELECT CFG_REQUEST_DEFN_SEQ.nextVal INTO v_RequestDefnId FROM DUAL;
	INSERT INTO AUTOSC.CFG_REQUEST_DEFN (REQUEST_DEFN_ID, REQUEST_TYPE_ID, MODALITY, MODEL_TYPE, REQUEST_DESC, INITIAL_TASK_ID, REQUESTER, VERIFIER, EXPIRES_ON) VALUES(v_RequestDefnId, (SELECT REQUEST_TYPE_ID FROM AUTOSC.CFG_REQUEST_TYPE WHERE REQUEST_TYPE_NAME='JUNIT_TEST_REQUEST_TYPE_07'), 'GSP', '_XPTEST', 'JUNIT_TEST_TYPE_DEFN_07', (SELECT TASK_TYPE_ID FROM AUTOSC.CFG_TASK_TYPE WHERE TASK_TYPE_NAME='JUNIT_TEST_TASK_TYPE_07_A'), 'navdeep.mahajan@ge.com', 'navdeep.mahajan@ge.com', (SYSDATE+365));
	
	INSERT INTO AUTOSC.CFG_TASK_CLASS_MAP (task_class_map_id, task_type_name, task_class) VALUES (CFG_TASK_CLASS_MAP_ID_SEQ.nextVal, 'JUNIT_TEST_TASK_TYPE_07_A', 'sweepTask');
	INSERT INTO AUTOSC.CFG_TASK_CLASS_MAP (task_class_map_id, task_type_name, task_class) VALUES (CFG_TASK_CLASS_MAP_ID_SEQ.nextVal, 'JUNIT_TEST_TASK_TYPE_07_B', 'fileCopyTask');
	INSERT INTO AUTOSC.CFG_TASK_CLASS_MAP (task_class_map_id, task_type_name, task_class) VALUES (CFG_TASK_CLASS_MAP_ID_SEQ.nextVal, 'JUNIT_TEST_TASK_TYPE_07_C', 'ftpTask');
	INSERT INTO AUTOSC.CFG_TASK_CLASS_MAP (task_class_map_id, task_type_name, task_class) VALUES (CFG_TASK_CLASS_MAP_ID_SEQ.nextVal, 'JUNIT_TEST_TASK_TYPE_07_D', 'sftpTask');
	
	INSERT INTO AUTOSC.CFG_TASK_RELATIONSHIP ( RELATION_ID, PARENT_ID, CHILD_ID) VALUES ( AUTOSC.CFG_TASK_RELATIONSHIP_SEQ.nextVal,(SELECT TASK_TYPE_ID FROM AUTOSC.CFG_TASK_TYPE WHERE TASK_TYPE_NAME='JUNIT_TEST_TASK_TYPE_07_A') , (SELECT TASK_TYPE_ID FROM AUTOSC.CFG_TASK_TYPE WHERE TASK_TYPE_NAME='JUNIT_TEST_TASK_TYPE_07_B'));
	INSERT INTO AUTOSC.CFG_TASK_RELATIONSHIP ( RELATION_ID, PARENT_ID, CHILD_ID) VALUES ( AUTOSC.CFG_TASK_RELATIONSHIP_SEQ.nextVal,(SELECT TASK_TYPE_ID FROM AUTOSC.CFG_TASK_TYPE WHERE TASK_TYPE_NAME='JUNIT_TEST_TASK_TYPE_07_A') , (SELECT TASK_TYPE_ID FROM AUTOSC.CFG_TASK_TYPE WHERE TASK_TYPE_NAME='JUNIT_TEST_TASK_TYPE_07_C'));
	INSERT INTO AUTOSC.CFG_TASK_RELATIONSHIP ( RELATION_ID, PARENT_ID, CHILD_ID) VALUES ( AUTOSC.CFG_TASK_RELATIONSHIP_SEQ.nextVal,(SELECT TASK_TYPE_ID FROM AUTOSC.CFG_TASK_TYPE WHERE TASK_TYPE_NAME='JUNIT_TEST_TASK_TYPE_07_A') , (SELECT TASK_TYPE_ID FROM AUTOSC.CFG_TASK_TYPE WHERE TASK_TYPE_NAME='JUNIT_TEST_TASK_TYPE_07_D'));
	
	--Selects have been added so that no automated test tries and use the same ids again
	Select CFG_SWEEP_PROPERTIES_SEQ.nextVal into v_SweepProp_Seq1 from dual;
	Select CFG_SWEEP_PROPERTIES_SEQ.nextVal into v_SweepProp_Seq2 from dual;
	Select CFG_SWEEP_PROPERTIES_SEQ.nextVal into v_SweepProp_Seq3 from dual;
	Select CFG_SWEEP_PROPERTIES_SEQ.nextVal into v_SweepProp_Seq4 from dual;
	INSERT INTO AUTOSC.CFG_SWEEP_PROPERTIES (SWEEP_PROP_ID, PROP_NAME, PROP_VALUE) values (v_SweepProp_Seq1, 'REMOTE_SCRIPT', 'test.sh');
	INSERT INTO AUTOSC.CFG_SWEEP_PROPERTIES (SWEEP_PROP_ID, PROP_NAME, PROP_VALUE) values (v_SweepProp_Seq2, 'EXECUTION_TIME', '80');
	INSERT INTO AUTOSC.CFG_SWEEP_PROPERTIES (SWEEP_PROP_ID, PROP_NAME, PROP_VALUE) values (v_SweepProp_Seq3, 'SCRIPT_NAME', 'test.sh');
	INSERT INTO AUTOSC.CFG_SWEEP_PROPERTIES (SWEEP_PROP_ID, PROP_NAME, PROP_VALUE) values (v_SweepProp_Seq4, 'SWEEP_DIR', 'test');
	
	INSERT INTO AUTOSC.CFG_REQUEST_DEFN_TO_SWEEP_PROP(REQUEST_DEFN_ID,SWEEP_PROP_ID) VALUES (v_RequestDefnId,v_SweepProp_Seq1);
	INSERT INTO AUTOSC.CFG_REQUEST_DEFN_TO_SWEEP_PROP(REQUEST_DEFN_ID,SWEEP_PROP_ID) VALUES (v_RequestDefnId,v_SweepProp_Seq2);
	INSERT INTO AUTOSC.CFG_REQUEST_DEFN_TO_SWEEP_PROP(REQUEST_DEFN_ID,SWEEP_PROP_ID) VALUES (v_RequestDefnId,v_SweepProp_Seq3);
	INSERT INTO AUTOSC.CFG_REQUEST_DEFN_TO_SWEEP_PROP(REQUEST_DEFN_ID,SWEEP_PROP_ID) VALUES (v_RequestDefnId,v_SweepProp_Seq4);
	
	--Selects have been added so that no automated test tries and use the same ids again
	Select CFG_SWEEP_FILE_INFO_SEQ.nextVal into v_SweepFI_Seq1 from dual;
	Select CFG_SWEEP_FILE_INFO_SEQ.nextVal into v_SweepFI_Seq2 from dual;
	Select CFG_SWEEP_FILE_INFO_SEQ.nextVal into v_SweepFI_Seq3 from dual;
	INSERT INTO AUTOSC.CFG_SWEEP_FILE_INFO(SWEEP_FILE_ID,LOCAL_FILE_NAME,REMOTE_FILE_NAME,DIRECTION,TRANSFER_MODE,FILE_TYPE,TRANSFER_ORDER) VALUES (v_SweepFI_Seq1,'test1.log','/tmp/test1.log','GET','BINARY','BINARY',1);
	INSERT INTO AUTOSC.CFG_SWEEP_FILE_INFO(SWEEP_FILE_ID,LOCAL_FILE_NAME,REMOTE_FILE_NAME,DIRECTION,TRANSFER_MODE,FILE_TYPE,TRANSFER_ORDER) VALUES (v_SweepFI_Seq2,'test2.log','/tmp/test2.log','GET','BINARY','BINARY',2);
	INSERT INTO AUTOSC.CFG_SWEEP_FILE_INFO(SWEEP_FILE_ID,LOCAL_FILE_NAME,REMOTE_FILE_NAME,DIRECTION,TRANSFER_MODE,FILE_TYPE,TRANSFER_ORDER) VALUES (v_SweepFI_Seq3,'test3.log','/tmp/test3.log','GET','BINARY','BINARY',3);
	
	INSERT INTO AUTOSC.CFG_REQUEST_DEFN_TO_SWEEP_FI(REQUEST_DEFN_ID,SWEEP_FILE_ID) VALUES (v_RequestDefnId,v_SweepFI_Seq1);
	INSERT INTO AUTOSC.CFG_REQUEST_DEFN_TO_SWEEP_FI(REQUEST_DEFN_ID,SWEEP_FILE_ID) VALUES (v_RequestDefnId,v_SweepFI_Seq2);
	INSERT INTO AUTOSC.CFG_REQUEST_DEFN_TO_SWEEP_FI(REQUEST_DEFN_ID,SWEEP_FILE_ID) VALUES (v_RequestDefnId,v_SweepFI_Seq3);
	
	INSERT INTO AUTOSC.CFG_TASK_FT_CONN_INFO(TASK_TYPE_NAME,HOST,LOGIN,PASSWORD) VALUES ('JUNIT_TEST_TASK_TYPE_07_C','10.99.97.214','insite','2getin');
	INSERT INTO AUTOSC.CFG_TASK_FT_CONN_INFO(TASK_TYPE_NAME,HOST,LOGIN,PASSWORD) VALUES ('JUNIT_TEST_TASK_TYPE_07_D','ins2d.med.ge.com','questra','qss04gst');
	
	INSERT INTO AUTOSC.CFG_TASK_FT_DETAILS(TASK_TYPE_NAME,LOG_FILE_PATTERN,ORDERING,TEMPLATE_DEF) VALUES ('JUNIT_TEST_TASK_TYPE_07_B','test1.log',1,'/home/autosc/data/TEST1/{$Prop:[Modality]}/{$Prop:[SystemId]}_{$FILENAME}');
	INSERT INTO AUTOSC.CFG_TASK_FT_DETAILS(TASK_TYPE_NAME,LOG_FILE_PATTERN,ORDERING,TEMPLATE_DEF) VALUES ('JUNIT_TEST_TASK_TYPE_07_C','.*',1,'/tmp/M/Mahajan/{$Prop:[Modality]}/{$Prop:[SystemId]}_{$FILENAME}');
	INSERT INTO AUTOSC.CFG_TASK_FT_DETAILS(TASK_TYPE_NAME,LOG_FILE_PATTERN,ORDERING,TEMPLATE_DEF) VALUES ('JUNIT_TEST_TASK_TYPE_07_D','.*',2,'/tmp/M/Mahajan/OtherTests/{$Prop:[Modality]}/{$Prop:[SystemId]}_{$FILENAME}');
	-- INSERT for table AUTOSC.CFG_TASK_FT_DETAILS
	INSERT INTO AUTOSC.CFG_TASK_FT_DETAILS(TASK_TYPE_NAME,LOG_FILE_PATTERN,ORDERING,TEMPLATE_DEF) VALUES ('JUNIT_TEST_TASK_TYPE_07_B','test2.log',2,'/home/autosc/data/TEST2/{$Prop:[Modality]}/{$Prop:[SystemId]}_{$FILENAME}');
	INSERT INTO AUTOSC.CFG_TASK_FT_DETAILS(TASK_TYPE_NAME,LOG_FILE_PATTERN,ORDERING,TEMPLATE_DEF) VALUES ('JUNIT_TEST_TASK_TYPE_07_B','test3.log',3,'/home/autosc/data/TEST3/{$Prop:[Modality]}/{$Prop:[SystemId]}_{$FILENAME}');
	INSERT INTO AUTOSC.CFG_TASK_FT_DETAILS(TASK_TYPE_NAME,LOG_FILE_PATTERN,ORDERING,TEMPLATE_DEF) VALUES ('JUNIT_TEST_TASK_TYPE_07_D','test2.log',1,'/tmp/M/Mahajan/Test2/{$Prop:[Modality]}/{$Prop:[SystemId]}_{$FILENAME}');
	Commit;
END;
/